#include <iostream>
using std::cout;
using std::endl;

class Point
{
public:
    Point(int x ,int y)
    : _ix(x)
    , _iy(y)
    {
        cout << "Point(int,int)" << endl;
    }

    Point(const Point & rhs)
    : _ix(rhs._ix)
    , _iy(rhs._iy)
    {
        cout << "Point(const Point &)" << endl;
    }
    

    void print(){
        cout << "(" << _ix
            << "," << _iy
            << ")" << endl;
    }

    ~Point(){
        cout << "~Point()" << endl;
    }
private:
    int _ix;
    int _iy;
};

void func1(Point & pt)//引用传递不会发生复制
{
    pt.print();
}

void test0(){
    Point p1(1,8);
    func1(p1);
}

//返回值为引用可以避免return时发生复制
//但要确保引用绑定的本体的生命周期比函数更长
Point p2(8,9);
Point & func2(){
    return p2;
}

void test1(){
    func2();
}



int main(void){
    test0();
    return 0;
}
